package cn.enilu.guns.utils;

public class IpUtils {

    /**
     * 检测IP地址是否正确
     * @param ip
     * @return
     */
    public static boolean isRightIP (String ip) {//
        return ip.matches(new MyRegex().pattern);
    }
    static class MyRegex
    {
        String pattern =
                "^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
                        "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
                        "([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\." +
                        "([01]?\\d\\d?|2[0-4]\\d|25[0-5])$";

    }
}
